#include "compressor.h"
#include <iostream>
#include <string.h>
#include <fstream>

using std::fstream;
using std::ios_base;
using std::cout;

int main (int argc, char** argv)
{
    if (argc != 4)
    {
        cout << "ERROR!!!: Incorrect argument count!!!\n";
        return 1;
    }
    
    Compressor compressor;
	
	if (strcmp (argv[1], "-compress") == 0)
	{
		compressor.Compress (argv [2], argv [3]);
		
			
	fstream in (argv [2], ios_base::in | ios_base::binary);
    in.seekg (0, ios_base::end);
    long long int in_size= in.tellg ();
	in.close ();
		  
	fstream out (argv [3], ios_base::in | ios_base::binary);
    out.seekg (0, ios_base::end);
    long long int out_size= out.tellg ();
	out.close ();
	
	double percentage = (in_size - out_size)*100.0/in_size;
	
	cout << "Compression: " << percentage << "%\n";
	}
		
	
	if (strcmp (argv[1], "-decompress") == 0)
	{
		compressor.Decompress (argv [2], argv [3]);
	}
	
	return 0;
}
